#ifndef SNAKE_H
#define SNAKE_H

#include <QMainWindow>



QT_BEGIN_NAMESPACE
namespace Ui { class Snake; }
QT_END_NAMESPACE

class Snake : public QMainWindow

{
    Q_OBJECT

public:
    Snake(QWidget *parent = nullptr);
    ~Snake();
    void paintEvent(QPaintEvent*event);//1
    void InitSnake();//3
    void keyPressEvent(QKeyEvent*event);//4
    QRect CreateFood();//产生食物//10
    void IsEat();//11
    void IsHit();//12
    void SpeedChange();//14
private slots://4
    void Snake_update();//4




private:
    Ui::Snake *ui;
    //QRect vSnakeRect;//3
    QTimer*timer;//定时器//4
    int nDirection;//蛇的移动方向
    bool blsRun;//是否开始//5
    bool blsOver;//是否结束//8
    QVector<QRect> vSnakeRect;//6
    QRect SnakeHead;//蛇头//7
    QString Display;//9
    QRect Food;//食物//10
    int Score;//得分//13
    int Speed;//14
};

#endif // SNAKE_H
